package com.sharelords.icp.web.result.helper;

import com.sharelords.icp.web.constant.ReturnCodeEnum;
import com.sharelords.icp.web.result.ViewResult;

/**
 * 视图结果集辅助类
 *
 * @author 夜舞旋
 */
public class ViewResultHelper {

    private ViewResultHelper() {
    }

    /**
     * 成功
     *
     * @param t
     * @param <T>
     * @return
     */
    public static <T> ViewResult<T> success(T t) {
        ViewResult<T> viewResult = new ViewResult<>();
        viewResult.success(t);
        return viewResult;
    }

    /**
     * 失败
     *
     * @param returnCodeEnum
     * @param <T>
     * @return
     */
    public static <T> ViewResult<T> failed(ReturnCodeEnum returnCodeEnum) {
        ViewResult<T> viewResult = new ViewResult<>();
        viewResult.failed(returnCodeEnum);
        return viewResult;
    }

    /**
     * 失败
     *
     * @param returnCodeEnum
     * @param t
     * @param <T>
     * @return
     */
    public static <T> ViewResult<T> failed(ReturnCodeEnum returnCodeEnum, T t) {
        ViewResult<T> viewResult = new ViewResult<>();
        viewResult.failed(returnCodeEnum, t);
        return viewResult;
    }

}
